/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.commands;

import client.*;
import client.anticheat.CheatingOffense;
import client.anticheat.ReportType;
import client.inventory.*;
import client.skills.Skill;
import client.skills.SkillEntry;
import client.skills.SkillFactory;
import com.alibaba.druid.pool.DruidPooledConnection;
import configs.ServerConfig;
import constants.*;
import constants.skills.尖兵;
import constants.skills.新手;
import constants.skills.管理员;
import database.DatabaseConnection;
import handling.channel.ChannelServer;
import handling.world.CheaterData;
import handling.world.World;
import handling.world.WorldBroadcastService;
import handling.world.WorldFindService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import provider.MapleData;
import provider.MapleDataProvider;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
import scripting.event.EventInstanceManager;
import scripting.event.EventManager;
import server.*;
import server.life.*;
import server.maps.*;
import server.quest.MapleQuest;
import server.shop.MapleShopFactory;
import server.squad.MapleSquad;
import server.squad.MapleSquadType;
import tools.*;
import tools.packet.EffectPacket;
import tools.packet.MobPacket;
import tools.packet.NPCPacket;

import java.awt.*;
import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.*;
import java.util.List;

/**
 * @author Emilyx3
 */
public class GMCommand {

    private static final Logger log = LogManager.getLogger(GMCommand.class);

    /**
     * @return
     */
    public static PlayerGMRank getPlayerLevelRequired() {
        return PlayerGMRank.GM;
    }


    public static class 地图信息 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            int xpos = c.getPlayer().getPosition().x;
            int ypos = c.getPlayer().getPosition().y;
            c.getPlayer().dropMessage(6, "当前地图信息: ID " + c.getPlayer().getMapId() + " 名字 " + c.getPlayer().getMap().getMapName() + " 当前坐标信息: " + xpos + " / " + ypos);
            return 1;
        }
    }


    public static class 学习技能 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            Skill skill = SkillFactory.getSkill(Integer.parseInt(splitted[1]));
            byte level = (byte) CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1);
            byte masterlevel = (byte) CommandProcessorUtil.getOptionalIntArg(splitted, 3, 1);

            if (level > skill.getMaxLevel()) {
                level = (byte) skill.getMaxLevel();
            }
            if (masterlevel > skill.getMaxLevel()) {
                masterlevel = (byte) skill.getMaxLevel();
            }
            c.getPlayer().changeSingleSkillLevel(skill, level, masterlevel);
            return 1;
        }
    }


    public static class 刷人气 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter player = c.getPlayer();
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !刷人气 <玩家名字> <要加人气的数量>");
                return 0;
            }
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            int fame = 0;
            try {
                fame = Integer.parseInt(splitted[2]);
            } catch (NumberFormatException nfe) {
                c.getPlayer().dropMessage(6, "输入的数字无效...");
                return 0;
            }
            if (victim != null && player.allowedToTarget(victim)) {
                victim.addFame(fame);
                victim.updateSingleStat(MapleStat.人气, victim.getFame());
                log.info("[命令] 管理员 " + player.getName() + " 给玩家 " + victim.getName() + " 加人气 " + fame + " 点.");
            }
            return 1;
        }
    }


    public static class 无敌 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter player = c.getPlayer();
            Skill skill = SkillFactory.getSkill(新手.金刚霸体);
            if (player.isInvincible()) {
                player.setInvincible(false);
                player.cancelEffect(skill.getEffect(1), false, -1);
                player.dropMessage(6, "无敌模式已关闭.");
            } else {
                player.setInvincible(true);
                skill.getEffect(1).applyTo(player);
                player.dropMessage(6, "无敌模式已开启.");
            }
            return 1;
        }
    }


    public static class 技能点 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            for (int i = 0; i < 4; i++) {
                c.getPlayer().setRemainingSp(CommandProcessorUtil.getOptionalIntArg(splitted, 1, 1), i);
            }
            c.getPlayer().updateSingleStat(MapleStat.AVAILABLESP, 0);
            return 1;
        }
    }


    public static class 职业 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "!职业 <职业ID>");
                return 0;
            }
            int jobId = Integer.parseInt(splitted[1]);
            if (JobConstants.getJobNameById(jobId).length() == 0) {
                c.getPlayer().dropMessage(5, "输入的职业id无效.");
                return 0;
            }
            c.getPlayer().changeJob(Integer.parseInt(splitted[1]));
            return 1;
        }
    }


    public static class 商店 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleShopFactory shop = MapleShopFactory.getInstance();
            int shopId = Integer.parseInt(splitted[1]);
            if (shop.getShop(shopId) != null) {
                shop.getShop(shopId).sendShop(c);
            }
            return 1;
        }
    }


    public static class 升级 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (c.getPlayer().getLevel() < 250) {
                c.getPlayer().gainExp(500000000, true, false, true);
            }
            return 1;
        }
    }


    public static class 刷道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            final int itemId = Integer.parseInt(splitted[1]);
            final short quantity = (short) CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1);
            if (!c.getPlayer().isAdmin()) {
                for (int i : GameConstants.itemBlock) {
                    if (itemId == i) {
                        c.getPlayer().dropMessage(5, "对不起，您当前管理权限无法刷出这个装备.");
                        return 0;
                    }
                }
            }
            if (!c.getPlayer().isSuperGM()) {
                switch (itemId / 10000) {
                    case 202:
                    case 204:
                    case 229: //技能书
                    case 251: //配方
                    case 253: //特殊卷轴
                    case 261: //武器上使用后可以突破伤害上限
                    case 400:
                    case 401:
                    case 402:
                    case 403:
                    case 413: //作辅助剂
                    case 417: //花生之类
                    case 425: //锻造道具
                    case 431:
                    case 506: //防暴卷轴
                        c.getPlayer().dropMessage(5, "对不起，您当前管理权限无法刷出这个装备.");
                        return 0;
                }
            }
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            if (ItemConstants.isPet(itemId)) {
                c.getPlayer().dropMessage(5, "宠物道具请通过商城购买.");
            } else if (!ii.itemExists(itemId)) {
                c.getPlayer().dropMessage(5, itemId + " 这个道具不存在.");
            } else {
                Item item;
                short flag = (short) ItemFlag.封印.getValue();
                if (ItemConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
                    item = ii.randomizeStats((Equip) ii.getEquipById(itemId));
                } else {
                    item = new client.inventory.Item(itemId, (byte) 0, !c.getPlayer().isSuperGM() ? 1 : quantity, (byte) 0);
                }
                if (!c.getPlayer().isSuperGM()) {
                    item.setFlag(flag);
                }
                if (!c.getPlayer().isAdmin()) {
                    item.setOwner(c.getPlayer().getName());
                }
                item.setGMLog(c.getPlayer().getName() + " 使用命令 !getitem");
                MapleInventoryManipulator.addbyItem(c, item);
                log.info("[命令] 管理员 " + c.getPlayer().getName() + " 刷道具: " + item.getItemId() + " 数量: " + item.getQuantity() + " 名称: " + ii.getName(itemId));
            }
            return 1;
        }
    }


    public static class 全服发放道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !全服发放道具 <道具ID> <道具数量>");
                return 0;
            }
            final int itemId = Integer.parseInt(splitted[1]);
            final short quantity = splitted.length < 3 ? 1 : (short) CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1);
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            if (!ii.itemExists(itemId)) {
                c.getPlayer().dropMessage(5, itemId + " 这个道具不存在.");
            } else if (ItemConstants.isPet(itemId)) {
                c.getPlayer().dropMessage(5, "宠物道具请通过商城购买.");
            }
            int succ = 0, error = 0;
            for (MapleCharacter player : ChannelServer.getInstance(1).getMapFactory().getMap(910000000).getCharacters()) {
                if (player != null && player.haveSpaceForId(itemId)) {
                    Item item;
                    if (ItemConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
                        item = ii.randomizeStats((Equip) ii.getEquipById(itemId));
                    } else {
                        item = new client.inventory.Item(itemId, (byte) 0, !c.getPlayer().isSuperGM() ? 1 : quantity, (byte) 0);
                    }
                    item.setGMLog(c.getPlayer().getName() + " 使用命令 !全服发放道具");
                    MapleInventoryManipulator.addbyItem(player.getClient(), item);
                    log.info("[命令] 管理员 " + c.getPlayer().getName() + " 使用全服刷道具, 玩家名: " + player.getName() + " 道具: " + item.getItemId() + " 数量: " + item.getQuantity() + " 名称: " + ii.getName(itemId));
                    player.dropMessage(1, "恭喜你获得管理员赠送的 " + ii.getName(itemId) + " " + quantity + "个。");
                    player.dropMessage(6, "[系统公告] 恭喜你获得管理员赠送的 " + ii.getName(itemId) + " " + quantity + "个。");
                    succ++;
                } else {
                    error++;
                }
            }
            c.getPlayer().dropMessage(1, "命令使用完毕。\r\n发送成功: " + succ + "\r\n发送失败: " + error);
            return 1;
        }
    }


    public static class 升级到 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !升级到 <等级>");
                return 0;
            }
            int change; //需要调整的等级
            try {
                change = Integer.parseInt(splitted[1]);
            } catch (NumberFormatException nfe) {
                c.getPlayer().dropMessage(6, "输入的数字无效.");
                return 0;
            }
            if (change <= 0 || change > 250) {
                c.getPlayer().dropMessage(6, "调整的等级范围出错，默认范围[1-250]");
                return 0;
            }
            int localLevel=c.getPlayer().getLevel();
            if(localLevel>change){
                c.getPlayer().setLevel((short) (change - 1)); //调整角色的等级为 当前调整的等级 - 1
                c.getPlayer().levelUp(); //触发角色升级效果
            }else{
                for(int i=0;i<change-localLevel;i++){
                    c.getPlayer().levelUp(); //触发角色升级效果
                    try {
                        Thread.sleep(200);//防止升太快
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

            return 1;
        }
    }


    public static class 删除道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 3) {
                c.getPlayer().dropMessage(6, "需要输入 <角色名字> <道具ID>");
                return 0;
            }
            MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (chr == null) {
                c.getPlayer().dropMessage(6, "输入的角色不存在或者角色不在线或者不在这个频道.");
                return 0;
            }
            chr.removeAll(Integer.parseInt(splitted[2]), false, false);
            c.getPlayer().dropMessage(6, "已经成功的将ID为: " + splitted[2] + " 的所有道具从角色: " + splitted[1] + " 的背包中删除.");
            return 1;
        }
    }


    public static class 锁定道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 3) {
                c.getPlayer().dropMessage(6, "Need <name> <itemid>");
                return 0;
            }
            MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (chr == null) {
                c.getPlayer().dropMessage(6, "输入的角色不存在或者角色不在线或者不在这个频道.");
                return 0;
            }
            int itemid = Integer.parseInt(splitted[2]);
            MapleInventoryType type = ItemConstants.getInventoryType(itemid);
            for (Item item : chr.getInventory(type).listById(itemid)) {
                item.setFlag((byte) (item.getFlag() | ItemFlag.封印.getValue()));
                chr.forceUpdateItem(item);
            }
            if (type == MapleInventoryType.EQUIP) {
                type = MapleInventoryType.EQUIPPED;
                for (Item item : chr.getInventory(type).listById(itemid)) {
                    item.setFlag((byte) (item.getFlag() | ItemFlag.封印.getValue()));
                    chr.forceUpdateItem(item);
                }
            }
            c.getPlayer().dropMessage(6, "已经成功的将ID为: " + splitted[2] + " 的所有道具锁定,执行角色为: " + splitted[1] + ".");
            return 1;
        }
    }


    public static class 杀死地图所有玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            for (MapleCharacter map : c.getPlayer().getMap().getCharactersThreadsafe()) {
                if (map != null && !map.isGM()) {
                    map.updateSingleStat(MapleStat.HP, 0);
                    map.updateSingleStat(MapleStat.MP, 0);
                    map.getStat().setHp((short) 0, map);
                    map.getStat().setMp((short) 0, map);
                }
            }
            return 1;
        }
    }


//    public static class Disease extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3) {
//                c.getPlayer().dropMessage(6, "!disease <type> [charname] <level> where type = SEAL/DARKNESS/WEAKEN/STUN/CURSE/POISON/SLOW/SEDUCE/REVERSE/ZOMBIFY/POTION/SHADOW/BLIND/FREEZE/POTENTIAL");
//                return 0;
//            }
//            int type = 0;
//            if (splitted[1].equalsIgnoreCase("SEAL")) {
//                type = 120;
//            } else if (splitted[1].equalsIgnoreCase("DARKNESS")) {
//                type = 121;
//            } else if (splitted[1].equalsIgnoreCase("WEAKEN")) {
//                type = 122;
//            } else if (splitted[1].equalsIgnoreCase("STUN")) {
//                type = 123;
//            } else if (splitted[1].equalsIgnoreCase("CURSE")) {
//                type = 124;
//            } else if (splitted[1].equalsIgnoreCase("POISON")) {
//                type = 125;
//            } else if (splitted[1].equalsIgnoreCase("SLOW")) {
//                type = 126;
//            } else if (splitted[1].equalsIgnoreCase("SEDUCE")) {
//                type = 128;
//            } else if (splitted[1].equalsIgnoreCase("REVERSE")) {
//                type = 132;
//            } else if (splitted[1].equalsIgnoreCase("ZOMBIFY")) {
//                type = 133;
//            } else if (splitted[1].equalsIgnoreCase("POTION")) {
//                type = 134;
//            } else if (splitted[1].equalsIgnoreCase("SHADOW")) {
//                type = 135;
//            } else if (splitted[1].equalsIgnoreCase("BLIND")) {
//                type = 136;
//            } else if (splitted[1].equalsIgnoreCase("FREEZE")) {
//                type = 137;
//            } else if (splitted[1].equalsIgnoreCase("POTENTIAL")) {
//                type = 138;
//            } else {
//                c.getPlayer().dropMessage(6, "!disease <type> [charname] <level> where type = SEAL/DARKNESS/WEAKEN/STUN/CURSE/POISON/SLOW/SEDUCE/REVERSE/ZOMBIFY/POTION/SHADOW/BLIND/FREEZE/POTENTIAL");
//                return 0;
//            }
//            if (splitted.length == 4) {
//                MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[2]);
//                if (victim == null) {
//                    c.getPlayer().dropMessage(5, "无法找到角色.");
//                    return 0;
//                }
//                victim.disease(type, CommandProcessorUtil.getOptionalIntArg(splitted, 3, 1));
//            } else {
//                for (MapleCharacter victim : c.getPlayer().getMap().getCharactersThreadsafe()) {
//                    victim.disease(type, CommandProcessorUtil.getOptionalIntArg(splitted, 3, 1));
//                }
//            }
//            return 1;
//        }
//    }
    public static class 开始事件 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (c.getPlayer().getEventInstance() != null) {
                c.getPlayer().dropMessage(5, "You are in one");
            } else if (splitted.length > 2) {
                EventManager em = c.getChannelServer().getEventSM().getEventManager(splitted[1]);
                if (em == null || em.getInstance(splitted[2]) == null) {
                    c.getPlayer().dropMessage(5, "Not exist");
                } else {
                    em.getInstance(splitted[2]).registerPlayer(c.getPlayer());
                }
            } else {
                c.getPlayer().dropMessage(5, "!开始事件 [eventmanager] [eventinstance]");
            }
            return 1;

        }
    }

    public static class 设置事件参数 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            EventManager em = c.getChannelServer().getEventSM().getEventManager(splitted[1]);
            if (em == null || em.getInstances().size() <= 0) {
                c.getPlayer().dropMessage(5, "none");
            } else {
                em.setProperty(splitted[2], splitted[3]);
                for (EventInstanceManager eim : em.getInstances()) {
                    eim.setProperty(splitted[2], splitted[3]);
                }
            }
            return 1;
        }
    }


    public static class 查看事件 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            EventManager em = c.getChannelServer().getEventSM().getEventManager(splitted[1]);
            if (em == null || em.getInstances().size() <= 0) {
                c.getPlayer().dropMessage(5, "none");
            } else {
                for (EventInstanceManager eim : em.getInstances()) {
                    c.getPlayer().dropMessage(5, "活动脚本: " + eim.getName() + ", eventManager: " + em.getName() + " iprops: " + eim.getProperty(splitted[2]) + ", eprops: " + em.getProperty(splitted[2]));
                }
            }
            return 0;
        }
    }




    public static class 当前地图玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            StringBuilder builder = new StringBuilder("当前地图玩家: ").append(c.getPlayer().getMap().getCharactersThreadsafe().size()).append(" 人. ");
            for (MapleCharacter chr : c.getPlayer().getMap().getCharactersThreadsafe()) {
                if (builder.length() > 150) { // wild guess :o
                    builder.setLength(builder.length() - 2);
                    c.getPlayer().dropMessage(6, builder.toString());
                    builder = new StringBuilder();
                }
                builder.append(MapleCharacterUtil.makeMapleReadable(chr.getName()));
                builder.append(", ");
            }
            builder.setLength(builder.length() - 2);
            c.getPlayer().dropMessage(6, builder.toString());
            return 1;
        }
    }


    public static class 通知 extends CommandExecute {

        /**
         * @param typestring
         * @return
         */
        protected static int getNoticeType(String typestring) {
            switch (typestring) {
                case "n":
                    return 0;
                case "p":
                    return 1;
                case "l":
                    return 2;
                case "nv":
                    return 5;
                case "v":
                    return 5;
                case "b":
                    return 6;
            }
            return -1;
        }

        @Override
        public int execute(MapleClient c, String[] splitted) {
            int joinmod = 1;
            int range = -1;
            switch (splitted[1]) {
                case "m":
                    range = 0;
                    break;
                case "c":
                    range = 1;
                    break;
                case "w":
                    range = 2;
                    break;
            }

            int tfrom = 2;
            if (range == -1) {
                range = 2;
                tfrom = 1;
            }
            int type = getNoticeType(splitted[tfrom]);
            if (type == -1) {
                type = 0;
                joinmod = 0;
            }
            StringBuilder sb = new StringBuilder();
            if (splitted[tfrom].equals("nv")) {
                sb.append("[Notice]");
            } else {
                sb.append("");
            }
            joinmod += tfrom;
            sb.append(StringUtil.joinStringFrom(splitted, joinmod));

            byte[] packet = MaplePacketCreator.serverNotice(type, sb.toString());
            if (range == 0) {
                c.getPlayer().getMap().broadcastMessage(packet);
            } else if (range == 1) {
                ChannelServer.getInstance(c.getChannel()).broadcastPacket(packet);
            } else if (range == 2) {
                WorldBroadcastService.getInstance().broadcastMessage(packet);
            }
            return 1;
        }
    }



    public static class 给技能 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 4) {
                c.getPlayer().dropMessage(6, "用法: !给技能 <玩家名字> <技能ID> <技能等级> <技能最大等级> [最后一项可以随便填写]");
                return 0;
            }
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            Skill skill = SkillFactory.getSkill(Integer.parseInt(splitted[2]));
            byte level = (byte) CommandProcessorUtil.getOptionalIntArg(splitted, 3, 1);
            byte masterlevel = (byte) CommandProcessorUtil.getOptionalIntArg(splitted, 4, 1);
            if (level > skill.getMaxLevel()) {
                level = (byte) skill.getMaxLevel();
            }
            if (masterlevel > skill.getMaxLevel()) {
                masterlevel = (byte) skill.getMaxLevel();
            }
            victim.changeSingleSkillLevel(skill, level, masterlevel);
            c.dropMessage("技能添加成功。");
            return 1;
        }
    }


    public static class 解锁道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            java.util.Map<Item, MapleInventoryType> eqs = new HashMap<>();
            boolean add = false;
            if (splitted.length < 2 || splitted[1].equals("all")) {
                for (MapleInventoryType type : MapleInventoryType.values()) {
                    for (Item item : c.getPlayer().getInventory(type)) {
                        if (ItemFlag.封印.check(item.getFlag())) {
                            item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                            add = true;
                            //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                        }
                        if (ItemFlag.不可交易.check(item.getFlag())) {
                            item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                            add = true;
                            //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                        }
                        if (add) {
                            eqs.put(item, type);
                        }
                        add = false;
                    }
                }
            } else if (splitted[1].equals("eqp")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).newList()) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.EQUIP);
                    }
                    add = false;
                }
            } else if (splitted[1].equals("eq")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.EQUIP)) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.EQUIP);
                    }
                    add = false;
                }
            } else if (splitted[1].equals("u")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.USE)) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.USE);
                    }
                    add = false;
                }
            } else if (splitted[1].equals("s")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.SETUP)) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.SETUP);
                    }
                    add = false;
                }
            } else if (splitted[1].equals("e")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.ETC)) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.ETC);
                    }
                    add = false;
                }
            } else if (splitted[1].equals("c")) {
                for (Item item : c.getPlayer().getInventory(MapleInventoryType.CASH)) {
                    if (ItemFlag.封印.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.封印.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (ItemFlag.不可交易.check(item.getFlag())) {
                        item.setFlag((byte) (item.getFlag() - ItemFlag.不可交易.getValue()));
                        add = true;
                        //c.announce(MaplePacketCreator.updateSpecialItemUse(item, type.getType()));
                    }
                    if (add) {
                        eqs.put(item, MapleInventoryType.CASH);
                    }
                    add = false;
                }
            } else {
                c.getPlayer().dropMessage(6, "[all/eqp/eq/u/s/e/c]");
            }

            for (Map.Entry<Item, MapleInventoryType> eq : eqs.entrySet()) {
                c.getPlayer().forceUpdateItem(eq.getKey().copy());
            }
            return 1;
        }
    }


    public static class 掉落 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !掉落  <itemid>");
                return 0;
            }
            int itemId = Integer.parseInt(splitted[1]);
            short quantity = (short) CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1);
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            if (ItemConstants.isPet(itemId)) {
                c.getPlayer().dropMessage(5, "宠物道具请通过商城购买.");
            } else if (!ii.itemExists(itemId)) {
                c.getPlayer().dropMessage(5, itemId + " 不存在.");
            } else {
                Item toDrop;
                if (ItemConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
                    toDrop = ii.randomizeStats((Equip) ii.getEquipById(itemId));
                } else {
                    toDrop = new client.inventory.Item(itemId, (byte) 0, quantity, (byte) 0);
                }
                if (!c.getPlayer().isAdmin()) {
                    toDrop.setGMLog(c.getPlayer().getName() + " 使用 !掉落");
                    toDrop.setOwner(c.getPlayer().getName());
                }
                c.getPlayer().getMap().spawnItemDrop(c.getPlayer(), c.getPlayer(), toDrop, c.getPlayer().getPosition(), true, true);
                c.getPlayer().dropMessage(6, "使用命令成功，丢出道具: " + toDrop.getItemId() + " - " + ii.getName(toDrop.getItemId()) + " 数量: " + toDrop.getQuantity());
                log.info("[命令] 管理员 " + c.getPlayer().getName() + " 丢道具: " + toDrop.getItemId() + " 数量: " + toDrop.getQuantity() + " 名称: " + ii.getName(toDrop.getItemId()));
            }
            return 1;
        }
    }


    public static class 结婚 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 3) {
                c.getPlayer().dropMessage(6, "用法: !结婚  <name> <itemid>");
                return 0;
            }
            int itemId = Integer.parseInt(splitted[2]);
            if (!ItemConstants.isEffectRing(itemId)) {
                c.getPlayer().dropMessage(6, "Invalid itemID.");
            } else {
                MapleCharacter fff = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                if (fff == null) {
                    c.getPlayer().dropMessage(6, "玩家必须在线.");
                } else {
                    int[] ringID = {MapleInventoryIdentifier.getInstance(), MapleInventoryIdentifier.getInstance()};
                    try {
                        MapleCharacter[] chrz = {fff, c.getPlayer()};
                        for (int i = 0; i < chrz.length; i++) {
                            Equip eq = (Equip) MapleItemInformationProvider.getInstance().getEquipById(itemId, ringID[i]);
                            if (eq == null) {
                                c.getPlayer().dropMessage(6, "Invalid itemID.");
                                return 0;
                            }
                            MapleInventoryManipulator.addbyItem(chrz[i].getClient(), eq.copy());
                            chrz[i].dropMessage(6, "结婚成功 " + chrz[i == 0 ? 1 : 0].getName());
                        }
                        MapleRing.addToDB(itemId, c.getPlayer(), fff.getName(), fff.getId(), ringID);
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
            }
            return 1;
        }
    }


//    public static class GivePoint extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3) {
//                c.getPlayer().dropMessage(6, "需要输入玩家的名字和数量.");
//                return 0;
//            }
//            MapleCharacter chrs = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//            if (chrs == null) {
//                c.getPlayer().dropMessage(6, "错误: 要操作的玩家必须是在同一线或者玩家不存在.");
//            } else {
//                chrs.setPoints(chrs.getPoints() + Integer.parseInt(splitted[2]));
//                c.getPlayer().dropMessage(6, splitted[1] + " has " + chrs.getPoints() + " points, after giving " + splitted[2] + ".");
//            }
//            return 1;
//        }
//    }


//    public static class GiveVPoint extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3) {
//                c.getPlayer().dropMessage(6, "需要输入玩家的名字和数量.");
//                return 0;
//            }
//            MapleCharacter chrs = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//            if (chrs == null) {
//                c.getPlayer().dropMessage(6, "错误: 要操作的玩家必须是在同一线或者玩家不存在.");
//            } else {
//                chrs.setVPoints(chrs.getVPoints() + Integer.parseInt(splitted[2]));
//                c.getPlayer().dropMessage(6, splitted[1] + " has " + chrs.getVPoints() + " vpoints, after giving " + splitted[2] + ".");
//            }
//            return 1;
//        }
//    }




    public static class 监视玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (target != null) {
                if (target.getClient().isMonitored()) {
                    target.getClient().setMonitored(false);
                    c.getPlayer().dropMessage(5, "停止对 " + target.getName() + " 的监视.");
                } else {
                    target.getClient().setMonitored(true);
                    c.getPlayer().dropMessage(5, "开始监视 " + target.getName() + " 的信息.");
                }
            } else {
                c.getPlayer().dropMessage(5, "当前频道没有找到该玩家.");
                return 0;
            }
            return 1;
        }
    }

    public static class 清怪 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleMap map = c.getPlayer().getMap();
            double range = Double.POSITIVE_INFINITY;
            if (splitted.length > 1) {
                int irange = Integer.parseInt(splitted[1]);
                if (splitted.length <= 2) {
                    range = irange * irange;
                } else {
                    map = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[2]));
                }
            }
            if (map == null) {
                c.getPlayer().dropMessage(6, "输入的地图不存在.");
                return 0;
            }
            MapleMonster mob;
            for (MapleMapObject monstermo : map.getMapObjectsInRange(c.getPlayer().getPosition(), range, Collections.singletonList(MapleMapObjectType.MONSTER))) {
                mob = (MapleMonster) monstermo;
                if (!mob.getStats().isBoss() || mob.getStats().isPartyBonus() || c.getPlayer().isGM()) {
                    map.killMonster(mob, c.getPlayer(), false, false, (byte) 1);
                }
            }
            return 1;
        }
    }
    public static class 清怪掉落 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleMap map = c.getPlayer().getMap();
            double range = Double.POSITIVE_INFINITY;

            if (splitted.length > 1) {
                //&& !splitted[0].equals("!killmonster") && !splitted[0].equals("!hitmonster") && !splitted[0].equals("!hitmonsterbyoid") && !splitted[0].equals("!killmonsterbyoid")) {
                int irange = Integer.parseInt(splitted[1]);
                if (splitted.length <= 2) {
                    range = irange * irange;
                } else {
                    map = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[2]));
                }
            }
            if (map == null) {
                c.getPlayer().dropMessage(6, "输入的地图不存在.");
                return 0;
            }
            MapleMonster mob;
            for (MapleMapObject monstermo : map.getMapObjectsInRange(c.getPlayer().getPosition(), range, Collections.singletonList(MapleMapObjectType.MONSTER))) {
                mob = (MapleMonster) monstermo;
                mob.damage(c.getPlayer(), mob.getHp(), false);
            }
            return 1;
        }
    }


    public static class 临时NPC extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            int npcId = Integer.parseInt(splitted[1]);
            MapleNPC npc = MapleLifeFactory.getNPC(npcId, c.getPlayer().getMapId());
            if (npc != null && !npc.getName().equals("MISSINGNO")) {
                npc.setPosition(c.getPlayer().getPosition());
                npc.setCy(c.getPlayer().getPosition().y);
                npc.setRx0(c.getPlayer().getPosition().x + 50);
                npc.setRx1(c.getPlayer().getPosition().x - 50);
                npc.setFh(c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition(), false).getId());
                npc.setCustom(true);
                c.getPlayer().getMap().addMapObject(npc);
                c.getPlayer().getMap().broadcastMessage(NPCPacket.spawnNPC(npc));
            } else {
                c.getPlayer().dropMessage(6, "你应该输入一个正确的 Npc-Id");
                return 0;
            }
            return 1;
        }
    }


    public static class 永久Npc extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 1) {
                c.getPlayer().dropMessage(6, "用法: !永久Npc <NpcID>");
                return 0;
            }
            int npcId = Integer.parseInt(splitted[1]);
            MapleNPC npc = MapleLifeFactory.getNPC(npcId, c.getPlayer().getMapId());
            if (npc != null && !npc.getName().equals("MISSINGNO")) {
                int xpos = c.getPlayer().getPosition().x;
                int ypos = c.getPlayer().getPosition().y;
                int fh = c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition(), false).getId();
                npc.setPosition(c.getPlayer().getPosition());
                npc.setCy(ypos);
                npc.setRx0(xpos + 50);
                npc.setRx1(xpos - 50);
                npc.setFh(fh);
                npc.setCustom(true);
                try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
                    PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
                    ps.setInt(1, npcId);
                    ps.setInt(2, 0);
                    ps.setInt(3, fh);
                    ps.setInt(4, ypos);
                    ps.setInt(4, ypos);
                    ps.setInt(5, xpos + 50);
                    ps.setInt(6, xpos - 50);
                    ps.setString(7, "n");
                    ps.setInt(8, xpos);
                    ps.setInt(9, ypos);
                    ps.setInt(10, c.getPlayer().getMapId());
                    ps.executeUpdate();
                } catch (SQLException e) {
                    c.getPlayer().dropMessage(6, "保存Npc信息到数据库中出现错误.");
                }
                c.getPlayer().getMap().addMapObject(npc);
                c.getPlayer().getMap().broadcastMessage(NPCPacket.spawnNPC(npc));
            } else {
                c.getPlayer().dropMessage(6, "你应该输入一个正确的 Npc-Id.");
                return 0;
            }
            return 1;
        }
    }


    public static class 创建永久怪物 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !创建永久怪物 <怪物ID> <刷新时间 默认按秒计算>");
                return 0;
            }
            int mobid = Integer.parseInt(splitted[1]);
            int mobTime = Integer.parseInt(splitted[2]);
            if (splitted[2] == null) {
                mobTime = 1;
            }
            MapleMonster mob = MapleLifeFactory.getMonster(mobid);
            if (mob != null) {
                int xpos = c.getPlayer().getPosition().x;
                int ypos = c.getPlayer().getPosition().y;
                int fh = c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition(), false).getId();
                mob.setPosition(c.getPlayer().getPosition());
                mob.setCy(ypos);
                mob.setRx0(xpos + 50);
                mob.setRx1(xpos - 50);
                mob.setFh(fh);
                try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
                    PreparedStatement ps = con.prepareStatement("INSERT INTO spawns ( idd, f, fh, cy, rx0, rx1, type, x, y, mid, mobtime ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
                    ps.setInt(1, mobid);
                    ps.setInt(2, 0);
                    ps.setInt(3, fh);
                    ps.setInt(4, ypos);
                    ps.setInt(5, xpos + 50);
                    ps.setInt(6, xpos - 50);
                    ps.setString(7, "m");
                    ps.setInt(8, xpos);
                    ps.setInt(9, ypos);
                    ps.setInt(10, c.getPlayer().getMapId());
                    ps.setInt(11, mobTime);
                    ps.executeUpdate();
                } catch (SQLException e) {
                    c.getPlayer().dropMessage(6, "保存Mob信息到数据库中出现错误.");
                }
                c.getPlayer().getMap().addMonsterSpawn(mob, mobTime, (byte) -1, null);
            } else {
                c.getPlayer().dropMessage(6, "你应该输入一个正确的 Mob-Id.");
                return 0;
            }
            return 1;
        }
    }


    public static class 创建玩家NPC extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            try {
                c.getPlayer().dropMessage(6, "Making playerNPC...");
                MapleCharacter chhr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                if (chhr == null) {
                    c.getPlayer().dropMessage(6, splitted[1] + " is not online");
                    return 0;
                }
                PlayerNPC npc = new PlayerNPC(chhr, Integer.parseInt(splitted[2]), c.getPlayer().getMap(), c.getPlayer());
                npc.addToServer();
                c.getPlayer().dropMessage(6, "Done");
            } catch (Exception e) {
                c.getPlayer().dropMessage(6, "NPC failed... : " + e.getMessage());
            }
            return 1;
        }
    }



    public static class 删除玩家NPC extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            try {
                c.getPlayer().dropMessage(6, "Destroying playerNPC...");
                MapleNPC npc = c.getPlayer().getMap().getNPCByOid(Integer.parseInt(splitted[1]));
                if (npc instanceof PlayerNPC) {
                    ((PlayerNPC) npc).destroy(null, true);
                    c.getPlayer().dropMessage(6, "Done");
                } else {
                    c.getPlayer().dropMessage(6, "!destroypnpc [objectid]");
                }
            } catch (Exception e) {
                c.getPlayer().dropMessage(6, "NPC failed... : " + e.getMessage());
            }
            return 1;
        }
    }


    public static class 顶部黄色公告 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            String outputMessage = StringUtil.joinStringFrom(splitted, 1);
            ServerConfig.LOGIN_SERVERMESSAGE = outputMessage;
            for (ChannelServer cserv : ChannelServer.getAllInstances()) {
                cserv.setServerMessage(outputMessage);
            }
            return 1;
        }
    }


    public static class 召唤 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            int mid = Integer.parseInt(splitted[1]);
            int num = Math.min(CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1), 50000);
            Integer level = CommandProcessorUtil.getNamedIntArg(splitted, 1, "lvl");
            Long hp = CommandProcessorUtil.getNamedLongArg(splitted, 1, "hp");
            Integer exp = CommandProcessorUtil.getNamedIntArg(splitted, 1, "exp");
            Double php = CommandProcessorUtil.getNamedDoubleArg(splitted, 1, "php");
            Double pexp = CommandProcessorUtil.getNamedDoubleArg(splitted, 1, "pexp");

            MapleMonster onemob;
            try {
                onemob = MapleLifeFactory.getMonster(mid);
            } catch (RuntimeException e) {
                c.getPlayer().dropMessage(5, "错误: " + e.getMessage());
                return 0;
            }
            if (onemob == null) {
                c.getPlayer().dropMessage(5, "输入的怪物不存在.");
                return 0;
            }
            long newhp = 0;
            int newexp = 0;
            if (hp != null) {
                newhp = hp;
            } else if (php != null) {
                newhp = (long) (onemob.getMobMaxHp() * (php / 100));
            } else {
                newhp = onemob.getMobMaxHp();
            }
            if (exp != null) {
                newexp = exp;
            } else if (pexp != null) {
                newexp = (int) (onemob.getMobExp() * (pexp / 100));
            } else {
                newexp = onemob.getMobExp();
            }
            if (newhp < 1) {
                newhp = 1;
            }

            OverrideMonsterStats overrideStats = new OverrideMonsterStats(newhp, onemob.getMobMaxMp(), newexp, false);

            for (int i = 0; i < num; i++) {
                MapleMonster mob = MapleLifeFactory.getMonster(mid);
                mob.setHp(newhp);
                if (level != null) {
                    mob.changeLevel(level, false);
                } else {
                    mob.setOverrideStats(overrideStats);
                }
                c.getPlayer().getMap().spawnMonsterOnGroundBelow(mob, c.getPlayer().getPosition());
            }
            return 1;
        }
    }
//
//
//    public static class PS extends CommandExecute {
//
//
//        protected static StringBuilder builder = new StringBuilder();
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (builder.length() > 1) {
//                c.announce(MaplePacketCreator.getPacketFromHexString(builder.toString()));
//                builder = new StringBuilder();
//            } else {
//                c.getPlayer().dropMessage(6, "请输入要测试的数据包信息!");
//            }
//            return 1;
//        }
//    }
//
//
//    public static class APS extends PS {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length > 1) {
//                builder.append(StringUtil.joinStringFrom(splitted, 1));
//                c.getPlayer().dropMessage(6, "String is now: " + builder.toString());
//            } else {
//                c.getPlayer().dropMessage(6, "请输入要测试的数据包信息!");
//            }
//            return 1;
//        }
//    }
//
//
//    public static class CPS extends PS {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            builder = new StringBuilder();
//            return 1;
//        }
//    }
//
//
//    public static class P extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length > 1) {
//                c.announce(MaplePacketCreator.getPacketFromHexString(StringUtil.joinStringFrom(splitted, 1)));
//            } else {
//                c.getPlayer().dropMessage(6, "请输入要测试的数据包信息!");
//            }
//            return 1;
//        }
//    }
//
//
//    public static class Packet extends P {
//    }




//
//    public static class FillBook extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            for (int e : MapleItemInformationProvider.getInstance().getMonsterBook().keySet()) {
//                c.getPlayer().getMonsterBook().getCards().put(e, 2);
//            }
//            c.getPlayer().getMonsterBook().changed();
//            c.getPlayer().dropMessage(5, "完成.");
//            return 1;
//        }
//    }

//    public static class FillPokedex extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            for (BattleConstants.PokedexEntry e : BattleConstants.getAllPokedex()) {
//                c.getPlayer().getMonsterBook().getCards().put(e.id, 2);
//            }
//            c.getPlayer().getMonsterBook().changed();
//            c.getPlayer().dropMessage(5, "操作完成.");
//            return 1;
//        }
//    }


//    public static class SeePokedex extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            for (BattleConstants.PokedexEntry e : BattleConstants.getAllPokedex()) {
//                c.getPlayer().getMonsterBook().getCards().put(e.id, 1);
//            }
//            c.getPlayer().getMonsterBook().changed();
//            c.getPlayer().dropMessage(5, "操作完成.");
//            return 1;
//        }
//    }
//
//
//    public static class ClearPokedex extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMonsterBook().getCards().clear();
//            c.getPlayer().getMonsterBook().changed();
//            c.getPlayer().dropMessage(5, "操作完成.");
//            return 1;
//        }
//    }
//
//
//    public static class GetPokemon extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (c.getPlayer().countBattlers() >= 6 || splitted.length < 2) {
//                c.getPlayer().dropMessage(5, "You have 6 pokemons already, !getpokemon <mobID>");
//                return 0;
//            }
//            MapleMonsterStats theMob = MapleLifeFactory.getMonsterStats(Integer.parseInt(splitted[1]));
//            if (theMob == null) {
//                c.getPlayer().dropMessage(5, "输入的怪物ID不存在.");
//                return 0;
//            }
//            Battler theB = new Battler(theMob.getLevel(), 0, c.getPlayer().getId(), theMob.getId(), theMob.getName(), BattleConstants.PokemonNature.randomNature(), 0, (byte) -1, (byte) 100, (byte) 100, (byte) 100, (byte) 100, (byte) 100, (byte) 100, (byte) 100, (byte) 100, (byte) Randomizer.nextInt(2));
//            if (theB.getFamily() == null) {
//                c.getPlayer().dropMessage(5, "mob cannot be used in pokemon.");
//                return 0;
//            }
//            c.getPlayer().getBattlers()[c.getPlayer().countBattlers()] = theB;
//            c.getPlayer().getMonsterBook().monsterCaught(c, theMob.getId(), theMob.getName());
//            c.getPlayer().changedBattler();
//            c.getPlayer().dropMessage(6, "操作完成.");
//            return 1;
//        }
//    }


    public static class 重载当前地图 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            int mapId = Integer.parseInt(splitted[1]);
            for (ChannelServer cserv : ChannelServer.getAllInstances()) {
                if (cserv.getMapFactory().isMapLoaded(mapId) && cserv.getMapFactory().getMap(mapId).getCharactersSize() > 0) {
                    c.getPlayer().dropMessage(5, "There exists characters on channel " + cserv.getChannel());
                    return 0;
                }
            }
            for (ChannelServer cserv : ChannelServer.getAllInstances()) {
                if (cserv.getMapFactory().isMapLoaded(mapId)) {
                    cserv.getMapFactory().removeMap(mapId);
                }
            }
            return 1;
        }
    }


    public static class 重置任务 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleQuest.getInstance(Integer.parseInt(splitted[1])).forfeit(c.getPlayer());
            return 1;
        }
    }


    public static class 开始任务 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleQuest.getInstance(Integer.parseInt(splitted[1])).start(c.getPlayer(), Integer.parseInt(splitted[2]));
            return 1;
        }
    }


    public static class 完成任务 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleQuest.getInstance(Integer.parseInt(splitted[1])).complete(c.getPlayer(), Integer.parseInt(splitted[2]), Integer.parseInt(splitted[3]));
            return 1;
        }
    }


    public static class 强制开始任务 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleQuest.getInstance(Integer.parseInt(splitted[1])).forceStart(c.getPlayer(), Integer.parseInt(splitted[2]), splitted.length >= 4 ? splitted[3] : null);
            return 1;
        }
    }


    public static class 强制完成任务 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleQuest.getInstance(Integer.parseInt(splitted[1])).forceComplete(c.getPlayer(), Integer.parseInt(splitted[2]));
            return 1;
        }
    }
//
//
//    public static class HReactor extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().getReactorByOid(Integer.parseInt(splitted[1])).hitReactor(c);
//            return 1;
//        }
//    }


//    public static class FHReactor extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().getReactorByOid(Integer.parseInt(splitted[1])).forceHitReactor(Byte.parseByte(splitted[2]));
//            return 1;
//        }
//    }
//
//
//
//
//    public static class SetReactor extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().setReactorState(Byte.parseByte(splitted[1]));
//            return 1;
//        }
//    }
//
//
//    public static class ResetReactor extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().resetReactors();
//            return 1;
//        }
//    }



    public static class 使用技能 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !使用技能 <技能ID> <技能等级>");
                return 0;
            }
            SkillFactory.getSkill(Integer.parseInt(splitted[1])).getEffect(Integer.parseInt(splitted[2])).applyTo(c.getPlayer());
            return 1;
        }
    }
    public static class 飞 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            SkillFactory.getSkill(尖兵.自由飞行).getEffect(1).applyTo(c.getPlayer());
            return 1;
        }
    }

    public static class 使用道具 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 1) {
                c.getPlayer().dropMessage(6, "用法: !使用道具 <道具ID>");
                return 0;
            }
            int itemId = Integer.parseInt(splitted[1]);
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            if (!ii.itemExists(itemId)) {
                c.getPlayer().dropMessage(5, itemId + " 这个道具不存在.");
                return 0;
            }
            ii.getItemEffect(Integer.parseInt(splitted[1])).applyTo(c.getPlayer());
            return 1;
        }
    }


//    public static class BuffItemEX extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 1) {
//                c.getPlayer().dropMessage(6, "用法: !BuffItemEX <道具ID>");
//                return 0;
//            }
//            int itemId = Integer.parseInt(splitted[1]);
//            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
//            if (!ii.itemExists(itemId)) {
//                c.getPlayer().dropMessage(5, itemId + " 这个道具不存在.");
//                return 0;
//            }
//            ii.getItemEffectEX(itemId).applyTo(c.getPlayer());
//            return 1;
//        }
//    }


//    public static class ItemSize extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().dropMessage(6, "当前加载的物品数量: " + MapleItemInformationProvider.getInstance().getAllItemSize());
//            return 1;
//        }
//    }


    public static class 漂浮公告 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !漂浮公告 <公告信息>");
                return 0;
            }
            int itemId = 5120010;
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            WorldBroadcastService.getInstance().startMapEffect(StringUtil.joinStringFrom(splitted, 2), itemId);
            return 1;
        }
    }


    public static class 刷新排行榜 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            RankingTop.getInstance().initAll();
            c.getPlayer().dropMessage(5, "排行榜刷新完成");
            return 1;
        }
    }
//
//    public static class checkGames extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                c.getPlayer().dropMessage(6, splitted[0] + " <使用方法：进程名/MD5>");
//                return 0;
//            }
//            int i = 0;
//            for (ChannelServer ch : ChannelServer.getAllInstances()) {
//                for (MapleCharacter chr : ch.getPlayerStorage().getAllCharacters()) {
//                    for (MapleProcess mp : chr.getProcess()) {
//                        if (mp.getMD5().equalsIgnoreCase(splitted[1]) || mp.getName().toLowerCase().contains(splitted[1].toLowerCase())) {
//                            c.getPlayer().dropMessage(5, "角色：" + chr.getName() + " 进程【\"" + mp.getPath() + "\" MD5：\"" + mp.getMD5() + "\"】");
//                            i++;
//                        }
//                    }
//                }
//            }
//            c.getPlayer().dropMessage(5, "进程检查完成，本次共检测到" + i + "个。");
//            return 1;
//        }
//    }

    public static class 重载签到奖励 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleSignin.getInstance().reload(true);
            c.dropMessage("签到奖励重载完成！");
            return 1;
        }
    }


    public static class 隐身 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            Skill skill = SkillFactory.getSkill(管理员.隐藏术);
            Skill skill2 = SkillFactory.getSkill(新手.金刚霸体);
            if (c.getPlayer().isHidden()) {
                c.getPlayer().cancelEffect(skill.getEffect(1), false, -1);
                c.getPlayer().cancelEffect(skill2.getEffect(1), false, -1);
                c.getPlayer().dropMessage(6, "隐身模式已关闭.");
            } else {
                skill.getEffect(1).applyTo(c.getPlayer());
                skill2.getEffect(1).applyTo(c.getPlayer());
                c.getPlayer().dropMessage(6, "隐身模式已开启.");
            }
            return 0;
        }
    }


    public static class 一血 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            c.getPlayer().updateSingleStat(MapleStat.HP, 1);
            c.getPlayer().updateSingleStat(MapleStat.MP, 1);
            c.getPlayer().getStat().setHp((short) 1, c.getPlayer());
            c.getPlayer().getStat().setMp((short) 1, c.getPlayer());
            return 0;
        }
    }


    public static class 复活自己 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            c.getPlayer().getStat().heal(c.getPlayer());
            c.getPlayer().dispelDebuffs();
            return 0;
        }
    }


    public static class 复活地图玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter player = c.getPlayer();
            for (MapleCharacter mch : player.getMap().getCharacters()) {
                if (mch != null) {
                    mch.getStat().setHp(mch.getStat().getMaxHp(), mch);
                    mch.updateSingleStat(MapleStat.HP, mch.getStat().getMaxHp());
                    mch.getStat().setMp(mch.getStat().getMaxMp(), mch);
                    mch.updateSingleStat(MapleStat.MP, mch.getStat().getMaxMp());
                    mch.dispelDebuffs();
                }
            }
            return 1;
        }
    }





    public static class 封号 extends CommandExecute {

        protected boolean hellban = false,


        ipBan = false;

        private String getCommand() {
            if (hellban) {
                return "HellBan";
            } else {
                return "Ban";
            }
        }

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 3) {
                c.getPlayer().dropMessage(5, "[用法] !封号 <角色名> <原因>");
                return 0;
            }
            StringBuilder sb = new StringBuilder();
            if (hellban) {
                sb.append("Banned ").append(splitted[1]).append(": ").append(StringUtil.joinStringFrom(splitted, 2));
            } else {
                sb.append(c.getPlayer().getName()).append(" banned ").append(splitted[1]).append(": ").append(StringUtil.joinStringFrom(splitted, 2));
            }
            MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (target != null) {
                if (c.getPlayer().getGMLevel() > target.getGMLevel() || c.getPlayer().isAdmin()) {
                    sb.append(" (IP: ").append(target.getClient().getSessionIPAddress()).append(")");
                    if (target.ban(sb.toString(), hellban || ipBan, false, hellban)) {
                        c.getPlayer().dropMessage(6, "[" + getCommand() + "] 已成功将玩家 " + splitted[1] + " 进行封号处理.");
                        return 1;
                    } else {
                        c.getPlayer().dropMessage(6, "[" + getCommand() + "] 封号失败.");
                        return 0;
                    }
                } else {
                    c.getPlayer().dropMessage(6, "[" + getCommand() + "] 对方的管理权限比你高无法对其进行封号...");
                    return 1;
                }
            } else {
                if (MapleCharacter.ban(splitted[1], sb.toString(), false, c.getPlayer().getGMLevel(), hellban)) { //c.getPlayer().isAdmin() ? 250 : 删除此项 以免封停玩家的IP错误
                    c.getPlayer().dropMessage(6, "[" + getCommand() + "] 已成功将玩家 " + splitted[1] + " 进行离线封号.");
                    return 1;
                } else {
                    c.getPlayer().dropMessage(6, "[" + getCommand() + "] 离线封号失败 " + splitted[1]);
                    return 0;
                }
            }
        }
    }


    public static class CC extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            c.getPlayer().changeChannel(Integer.parseInt(splitted[1]));
            return 1;
        }
    }




    public static class 踢下线 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[splitted.length - 1]);
            if (victim != null && c.getPlayer().getGMLevel() >= victim.getGMLevel()) {
                victim.getClient().disconnect(true, false);
                victim.getClient().getSession().close();
                c.getPlayer().dropMessage(6, "已经成功断开 " + victim.getName() + " 的连接.");
                return 1;
            } else {
                c.getPlayer().dropMessage(6, "使用的对象不存在或者角色名字错误或者对方的GM权限比你高.");
                return 0;
            }
        }
    }


    public static class 杀玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter player = c.getPlayer();
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "用法: !杀玩家 <list player names>");
                return 0;
            }
            MapleCharacter victim = null;
            for (int i = 1; i < splitted.length; i++) {
                try {
                    victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[i]);
                } catch (Exception e) {
                    c.getPlayer().dropMessage(6, "没有找到名字为: " + splitted[i] + " 的玩家.");
                }
                if (player.allowedToTarget(victim) && player.getGMLevel() >= victim.getGMLevel()) {
                    victim.updateSingleStat(MapleStat.HP, 0);
                    victim.updateSingleStat(MapleStat.MP, 0);
                    victim.getStat().setHp((short) 0, victim);
                    victim.getStat().setMp((short) 0, victim);
                    c.announce(EffectPacket.playerDeadConfirm(1, 0));
                }
            }
            return 1;
        }
    }


    public static class 清包 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            java.util.Map<Pair<Short, Short>, MapleInventoryType> eqs = new HashMap<>();
            switch (splitted[1]) {
                case "all":
                    for (MapleInventoryType type : MapleInventoryType.values()) {
                        for (Item item : c.getPlayer().getInventory(type)) {
                            eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), type);
                        }
                    }
                    break;
                case "eqp":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.EQUIPPED)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.EQUIPPED);
                    }
                    break;
                case "eq":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.EQUIP)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.EQUIP);
                    }
                    break;
                case "u":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.USE)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.USE);
                    }
                    break;
                case "s":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.SETUP)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.SETUP);
                    }
                    break;
                case "e":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.ETC)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.ETC);
                    }
                    break;
                case "c":
                    for (Item item : c.getPlayer().getInventory(MapleInventoryType.CASH)) {
                        eqs.put(new Pair<>(item.getPosition(), item.getQuantity()), MapleInventoryType.CASH);
                    }
                    break;
                default:
                    c.getPlayer().dropMessage(6, "[all/eqp/eq/u/s/e/c]");
                    break;
            }
            for (Map.Entry<Pair<Short, Short>, MapleInventoryType> eq : eqs.entrySet()) {
                MapleInventoryManipulator.removeFromSlot(c, eq.getValue(), eq.getKey().left, eq.getKey().right, false, false);
            }
            return 1;
        }
    }

//    public static class ItemCheck extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3 || splitted[1] == null || splitted[1].equals("") || splitted[2] == null || splitted[2].equals("")) {
//                c.getPlayer().dropMessage(6, "用法: !itemcheck <玩家名字> <道具ID>");
//                return 0;
//            } else {
//                int item = Integer.parseInt(splitted[2]);
//                MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//                int itemamount = chr.getItemQuantity(item, true);
//                if (itemamount > 0) {
//                    c.getPlayer().dropMessage(6, chr.getName() + " 拥有 " + itemamount + " (" + item + ").");
//                } else {
//                    c.getPlayer().dropMessage(6, chr.getName() + " 没有ID为 (" + item + ") 的道具.");
//                }
//            }
//            return 1;
//        }
//    }

//
//    public static class Song extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.musicChange(splitted[1]));
//            return 1;
//        }
//    }

//
//    public static class CheckPoint extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                c.getPlayer().dropMessage(6, "请输入玩家的名字.");
//                return 0;
//            }
//            MapleCharacter chrs = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//            if (chrs == null) {
//                c.getPlayer().dropMessage(6, "当前频道么有找到这个玩家.");
//            } else {
//                c.getPlayer().dropMessage(6, chrs.getName() + " 拥有 " + chrs.getPoints() + " 点.");
//            }
//            return 1;
//        }
//    }

//
//    public static class CheckVPoint extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                c.getPlayer().dropMessage(6, "请输入玩家的名字.");
//                return 0;
//            }
//            MapleCharacter chrs = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//            if (chrs == null) {
//                c.getPlayer().dropMessage(6, "当前频道么有找到这个玩家");
//            } else {
//                c.getPlayer().dropMessage(6, chrs.getName() + " 拥有 " + chrs.getVPoints() + " 点.");
//            }
//            return 1;
//        }
//    }

//
//    public static class PermWeather extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (c.getPlayer().getMap().getPermanentWeather() > 0) {
//                c.getPlayer().getMap().setPermanentWeather(0);
//                c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.removeMapEffect());
//                c.getPlayer().dropMessage(5, "当前地图的效果已禁止.");
//            } else {
//                int weather = CommandProcessorUtil.getOptionalIntArg(splitted, 1, 5120000);
//                if (!MapleItemInformationProvider.getInstance().itemExists(weather) || weather / 10000 != 512) {
//                    c.getPlayer().dropMessage(5, "请输入ID.");
//                } else {
//                    c.getPlayer().getMap().setPermanentWeather(weather);
//                    c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.startMapEffect("", weather, false));
//                    c.getPlayer().dropMessage(5, "当前地图的效果已开启.");
//                }
//            }
//            return 1;
//        }
//    }


    public static class 角色信息 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            StringBuilder builder = new StringBuilder();
            MapleCharacter other = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (other == null) {
                builder.append("输入的角色不存在...");
                c.getPlayer().dropMessage(6, builder.toString());
                return 0;
            }
            if (other.getClient().getLastPing() <= 0) {
                other.getClient().sendPing();
            }
            builder.append(MapleClient.getLogMessage(other, ""));
            builder.append(" 坐标 ").append(other.getPosition().x);
            builder.append(" /").append(other.getPosition().y);

            builder.append(" || 血 : ");
            builder.append(other.getStat().getHp());
            builder.append(" /");
            builder.append(other.getStat().getCurrentMaxHp());

            builder.append(" || 蓝 : ");
            builder.append(other.getStat().getMp());
            builder.append(" /");
            builder.append(other.getStat().getCurrentMaxMp(other.getJob()));

            builder.append(" || 物理攻击力 : ");
            builder.append(other.getStat().getTotalWatk());
            builder.append(" || 魔法攻击力 : ");
            builder.append(other.getStat().getTotalMagic());
            builder.append(" || 最大攻击 : ");
            builder.append(other.getStat().getCurrentMaxBaseDamage());
            builder.append(" || 伤害% : ");
            builder.append(other.getStat().getDamageRate());
            builder.append(" || BOSS伤害% : ");
            builder.append(other.getStat().getBossDamageRate());
            builder.append(" || 爆击几率 : ");
            builder.append(other.getStat().passive_sharpeye_rate());
            builder.append(" || 暴击伤害 : ");
            builder.append(other.getStat().passive_sharpeye_percent());

            builder.append(" || 力量 : ");
            builder.append(other.getStat().getStr());
            builder.append(" || 敏捷 : ");
            builder.append(other.getStat().getDex());
            builder.append(" || 智力 : ");
            builder.append(other.getStat().getInt());
            builder.append(" || 运气 : ");
            builder.append(other.getStat().getLuk());

            builder.append(" || 全部力量 : ");
            builder.append(other.getStat().getTotalStr());
            builder.append(" || 全部敏捷 : ");
            builder.append(other.getStat().getTotalDex());
            builder.append(" || 全部智力 : ");
            builder.append(other.getStat().getTotalInt());
            builder.append(" || 全部运气 : ");
            builder.append(other.getStat().getTotalLuk());

            builder.append(" || 经验 : ");
            builder.append(other.getExp());
            builder.append(" || 金币 : ");
            builder.append(other.getMeso());

            builder.append(" || 是否组队 : ");
            builder.append(other.getParty() == null ? -1 : other.getParty().getPartyId());

            builder.append(" || 是否交易: ");
            builder.append(other.getTrade() != null);
            builder.append(" || Latency: ");
            builder.append(other.getClient().getLatency());
            builder.append(" || PING: ");
            builder.append(other.getClient().getLastPing());
            builder.append(" || PONG: ");
            builder.append(other.getClient().getLastPong());

            c.getPlayer().dropMessage(6, builder.toString());
            return 1;
        }
    }


//    public static class Reports extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            java.util.List<CheaterData> cheaters = World.getReports();
//            for (int x = cheaters.size() - 1; x >= 0; x--) {
//                CheaterData cheater = cheaters.get(x);
//                c.getPlayer().dropMessage(6, cheater.getInfo());
//            }
//            return 1;
//        }
//    }
//
//
//    public static class ClearReport extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3) {
//                StringBuilder ret = new StringBuilder("用法 !report [ign] [all/");
//                for (ReportType type : ReportType.values()) {
//                    ret.append(type.theId).append('/');
//                }
//                ret.setLength(ret.length() - 1);
//                c.getPlayer().dropMessage(6, ret.append(']').toString());
//                return 0;
//            }
//            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
//            if (victim == null) {
//                c.getPlayer().dropMessage(5, "输入的角色不存在...");
//                return 0;
//            }
//            ReportType type = ReportType.getByString(splitted[2]);
//            if (type != null) {
//                victim.clearReports(type);
//            } else {
//                victim.clearReports();
//            }
//            c.getPlayer().dropMessage(5, "完成.");
//            return 1;
//        }
//    }


    public static class 检测作弊 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            java.util.List<CheaterData> cheaters = World.getCheaters();
            for (int x = cheaters.size() - 1; x >= 0; x--) {
                CheaterData cheater = cheaters.get(x);
                c.getPlayer().dropMessage(6, cheater.getInfo());
            }
            return 1;
        }
    }

//
//
//    public static class SpawnDebug extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().dropMessage(6, c.getPlayer().getMap().spawnDebug());
//            return 1;
//        }
//    }
//

    public static class 刷新人物数据 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            c.getPlayer().fakeRelog();
            return 1;
        }
    }

//
//    public static class RemoveDrops extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().dropMessage(5, "已成功将当前地图的 " + c.getPlayer().getMap().getNumItems() + " 个道具清除.");
//            c.getPlayer().getMap().removeDrops();
//            return 1;
//        }
//    }
//
//
//    public static class ListSquads extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            for (Map.Entry<MapleSquadType, MapleSquad> squads : c.getChannelServer().getAllSquads().entrySet()) {
//                c.getPlayer().dropMessage(5, "类型: " + squads.getKey().name() + ", 队长: " + squads.getValue().getLeader().getName() + ", 状态: " + squads.getValue().getStatus() + ", 注册成员数量: " + squads.getValue().getSquadSize() + ", 禁止成员数量: " + squads.getValue().getBannedMemberSize());
//            }
//            return 0;
//        }
//    }
//
//
//    public static class ListInstances extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            EventManager em = c.getChannelServer().getEventSM().getEventManager(StringUtil.joinStringFrom(splitted, 1));
//            if (em == null || em.getInstances().size() <= 0) {
//                c.getPlayer().dropMessage(5, "没有找到.");
//            } else {
//                for (EventInstanceManager eim : em.getInstances()) {
//                    c.getPlayer().dropMessage(5, "Event " + eim.getName() + ", charSize: " + eim.getPlayers().size() + ", dcedSize: " + eim.getDisconnected().size() + ", mobSize: " + eim.getMobs().size() + ", eventManager: " + em.getName() + ", timeLeft: " + eim.getTimeLeft() + ", iprops: " + eim.getProperties().toString() + ", eprops: " + em.getProperties().toString());
//                }
//            }
//            return 0;
//        }
//    }
//
//
//    public static class Uptime extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().dropMessage(6, "Server has been up for " + StringUtil.getReadableMillis(ChannelServer.serverStartTime, System.currentTimeMillis()));
//            return 1;
//        }
//    }
//
//
//    public static class EventInstance extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (c.getPlayer().getEventInstance() == null) {
//                c.getPlayer().dropMessage(5, "没有找到.");
//            } else {
//                EventInstanceManager eim = c.getPlayer().getEventInstance();
//                c.getPlayer().dropMessage(5, "Event " + eim.getName() + ", charSize: " + eim.getPlayers().size() + ", dcedSize: " + eim.getDisconnected().size() + ", mobSize: " + eim.getMobs().size() + ", eventManager: " + eim.getEventManager().getName() + ", timeLeft: " + eim.getTimeLeft() + ", iprops: " + eim.getProperties().toString() + ", eprops: " + eim.getEventManager().getProperties().toString());
//            }
//            return 1;
//        }
//    }
//
//
//    public static class GoTo extends CommandExecute {
//
//        private static final HashMap<String, Integer> gotomaps = new HashMap<>();
//
//        static {
//            gotomaps.put("gmmap", 180000000);
//            gotomaps.put("southperry", 2000000);
//            gotomaps.put("amherst", 1010000);
//            gotomaps.put("henesys", 100000000);
//            gotomaps.put("ellinia", 101000000);
//            gotomaps.put("perion", 102000000);
//            gotomaps.put("kerning", 103000000);
//            gotomaps.put("harbor", 104000000);
//            gotomaps.put("sleepywood", 105000000);
//            gotomaps.put("florina", 120000300);
//            gotomaps.put("orbis", 200000000);
//            gotomaps.put("happyville", 209000000);
//            gotomaps.put("elnath", 211000000);
//            gotomaps.put("ludibrium", 220000000);
//            gotomaps.put("aquaroad", 230000000);
//            gotomaps.put("leafre", 240000000);
//            gotomaps.put("mulung", 250000000);
//            gotomaps.put("herbtown", 251000000);
//            gotomaps.put("omegasector", 221000000);
//            gotomaps.put("koreanfolktown", 222000000);
//            gotomaps.put("newleafcity", 600000000);
//            gotomaps.put("sharenian", 990000000);
//            gotomaps.put("pianus", 230040420);
//            gotomaps.put("horntail", 240060200);
//            gotomaps.put("chorntail", 240060201);
//            gotomaps.put("griffey", 240020101);
//            gotomaps.put("manon", 240020401);
//            gotomaps.put("zakum", 280030100);
//            gotomaps.put("czakum", 280030001);
//            gotomaps.put("papulatus", 220080001);
//            gotomaps.put("showatown", 801000000);
//            gotomaps.put("zipangu", 800000000);
//            gotomaps.put("ariant", 260000100);
//            gotomaps.put("nautilus", 120000000);
//            gotomaps.put("boatquay", 541000000);
//            gotomaps.put("malaysia", 550000000);
//            gotomaps.put("erev", 130000000);
//            gotomaps.put("ellin", 300000000);
//            gotomaps.put("kampung", 551000000);
//            gotomaps.put("singapore", 540000000);
//            gotomaps.put("amoria", 680000000);
//            gotomaps.put("timetemple", 270000000);
//            gotomaps.put("pinkbean", 270050100);
//            gotomaps.put("fm", 910000000);
//            gotomaps.put("freemarket", 910000000);
//            gotomaps.put("oxquiz", 109020001);
//            gotomaps.put("ola", 109030101);
//            gotomaps.put("fitness", 109040000);
//            gotomaps.put("snowball", 109060000);
//            gotomaps.put("golden", 950100000);
//            gotomaps.put("phantom", 610010000);
//            gotomaps.put("cwk", 610030000);
//            gotomaps.put("rien", 140000000);
//            gotomaps.put("edel", 310000000);
//            gotomaps.put("ardent", 910001000);
//            gotomaps.put("craft", 910001000);
//            gotomaps.put("pvp", 960000000);
//            gotomaps.put("future", 271000000);
//        }
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                c.getPlayer().dropMessage(6, "用法: !goto <mapname>");
//            } else {
//                if (gotomaps.containsKey(splitted[1])) {
//                    MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(splitted[1]));
//                    if (target == null) {
//                        c.getPlayer().dropMessage(6, "输入的地图不存在.");
//                        return 0;
//                    }
//                    MaplePortal targetPortal = target.getPortal(0);
//                    c.getPlayer().changeMap(target, targetPortal);
//                } else {
//                    if (splitted[1].equals("locations")) {
//                        c.getPlayer().dropMessage(6, "Use !goto <location>. Locations are as follows:");
//                        StringBuilder sb = new StringBuilder();
//                        for (String s : gotomaps.keySet()) {
//                            sb.append(s).append(", ");
//                        }
//                        c.getPlayer().dropMessage(6, sb.substring(0, sb.length() - 2));
//                    } else {
//                        c.getPlayer().dropMessage(6, "Invalid command syntax - Use !goto <location>. For a list of locations, use !goto locations.");
//                    }
//                }
//            }
//            return 1;
//        }
//    }
//
//
//    public static class MonsterDebug extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            MapleMap map = c.getPlayer().getMap();
//            double range = Double.POSITIVE_INFINITY;
//
//            if (splitted.length > 1) {
//                //&& !splitted[0].equals("!killmonster") && !splitted[0].equals("!hitmonster") && !splitted[0].equals("!hitmonsterbyoid") && !splitted[0].equals("!killmonsterbyoid")) {
//                int irange = Integer.parseInt(splitted[1]);
//                if (splitted.length <= 2) {
//                    range = irange * irange;
//                } else {
//                    map = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[2]));
//                }
//            }
//            if (map == null) {
//                c.getPlayer().dropMessage(6, "输入的地图ID无效.");
//                return 0;
//            }
//            MapleMonster mob;
//            for (MapleMapObject monstermo : map.getMapObjectsInRange(c.getPlayer().getPosition(), range, Collections.singletonList(MapleMapObjectType.MONSTER))) {
//                mob = (MapleMonster) monstermo;
//                c.getPlayer().dropMessage(6, "怪物: " + mob.toString());
//            }
//            return 1;
//        }
//    }
//

    public static class 查看NPC extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            for (MapleMapObject reactor1l : c.getPlayer().getMap().getAllNPCsThreadsafe()) {
                MapleNPC reactor2l = (MapleNPC) reactor1l;
                c.getPlayer().dropMessage(5, "NPC信息: 工作ID: " + reactor2l.getObjectId() + " npcID: " + reactor2l.getId() + " 位置: " + reactor2l.getPosition().toString() + " 名字: " + reactor2l.getName());
            }
            return 0;
        }
    }


    public static class 查看反应堆 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            for (MapleMapObject reactor1l : c.getPlayer().getMap().getAllReactorsThreadsafe()) {
                MapleReactor reactor2l = (MapleReactor) reactor1l;
                c.getPlayer().dropMessage(5, "反应堆信息: 工作ID: " + reactor2l.getObjectId() + " reactorID: " + reactor2l.getReactorId() + " 位置: " + reactor2l.getPosition().toString() + " 状态: " + reactor2l.getState() + " 名字: " + reactor2l.getName());
            }
            return 0;
        }
    }


    public static class 查看传送门 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            for (MaplePortal portal : c.getPlayer().getMap().getPortals()) {
                c.getPlayer().dropMessage(5, "传送门信息: ID: " + portal.getId() + " script: " + portal.getScriptName() + " name: " + portal.getName() + " pos: " + portal.getPosition().x + "," + portal.getPosition().y + " target: " + portal.getTargetMapId() + " / " + portal.getTarget());
            }
            return 0;
        }
    }

//
//    public static class MyNPCPos extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            Point pos = c.getPlayer().getPosition();
//            c.getPlayer().dropMessage(6, "X: " + pos.x + " | Y: " + pos.y + " | RX0: " + (pos.x + 50) + " | RX1: " + (pos.x - 50) + " | FH: " + c.getPlayer().getFH());
//            return 1;
//        }
//    }
//
//
//    public static class Clock extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getClock(CommandProcessorUtil.getOptionalIntArg(splitted, 1, 60)));
//            return 1;
//        }
//    }
//

    public static class 传送玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (victim != null) {
                if (c.getPlayer().inPVP() || (!c.getPlayer().isGM() && (victim.isInBlockedMap() || victim.isGM()))) {
                    c.getPlayer().dropMessage(5, "请稍后在试.");
                    return 0;
                }
                victim.changeMap(c.getPlayer().getMap(), c.getPlayer().getMap().findClosestPortal(c.getPlayer().getTruePosition()));
            } else {
                int ch = WorldFindService.getInstance().findChannel(splitted[1]);
                if (ch < 0) {
                    c.getPlayer().dropMessage(5, "没有找到玩家[" + splitted[1] + "],请确认玩家是否在线或者输入的角色名字是否正确.");
                    return 0;
                }
                victim = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(splitted[1]);
                if (victim == null || victim.inPVP() || (!c.getPlayer().isGM() && (victim.isInBlockedMap() || victim.isGM()))) {
                    c.getPlayer().dropMessage(5, "请稍后在试.");
                    return 0;
                }
                c.getPlayer().dropMessage(5, "Victim is cross changing channel.");
                victim.dropMessage(5, "Cross changing channel.");
                if (victim.getMapId() != c.getPlayer().getMapId()) {
                    MapleMap mapp = victim.getClient().getChannelServer().getMapFactory().getMap(c.getPlayer().getMapId());
                    victim.changeMap(mapp, mapp.findClosestPortal(c.getPlayer().getTruePosition()));
                }
                victim.changeChannel(c.getChannel());
            }
            return 1;
        }
    }


    public static class 传送所有玩家 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            boolean all = splitted.length > 1;
            for (ChannelServer cs : ChannelServer.getAllInstances()) {
                for (MapleCharacter chr : cs.getPlayerStorage().getAllCharacters()) {
                    if (chr == null || chr.isGM() || (chr.isInBlockedMap() && !all)) {
                        continue;
                    }
                    chr.changeMap(c.getPlayer().getMap(), c.getPlayer().getMap().findClosestPortal(c.getPlayer().getTruePosition()));
                    chr.dropMessage(5, "您已被GM传送于此。");
                    if (chr.getClient().getChannel() != c.getChannel()) {
                        chr.changeChannel(c.getChannel());
                    }
                }
            }
            return 1;
        }
    }


    public static class 传送 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (victim != null && c.getPlayer().getGMLevel() >= victim.getGMLevel() && !victim.inPVP() && !c.getPlayer().inPVP()) {
                if (splitted.length == 2) {
                    c.getPlayer().changeMap(victim.getMap(), victim.getMap().findClosestSpawnpoint(victim.getTruePosition()));
                } else {
                    MapleMap target = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(Integer.parseInt(splitted[2]));
                    if (target == null) {
                        c.getPlayer().dropMessage(6, "输入的地图不存在.");
                        return 0;
                    }
                    MaplePortal targetPortal = null;
                    if (splitted.length > 3) {
                        try {
                            targetPortal = target.getPortal(Integer.parseInt(splitted[3]));
                        } catch (IndexOutOfBoundsException e) {
                            // noop, assume the gm didn't know how many portals there are
                            c.getPlayer().dropMessage(5, "Invalid portal selected.");
                        } catch (NumberFormatException a) {
                            // noop, assume that the gm is drunk
                        }
                    }
                    if (targetPortal == null) {
                        targetPortal = target.getPortal(0);
                    }
                    victim.changeMap(target, targetPortal);
                }
            } else {
                try {
                    victim = c.getPlayer();
                    int ch = WorldFindService.getInstance().findChannel(splitted[1]);
                    if (ch < 0) {
                        MapleMap target = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[1]));
                        if (target == null) {
                            c.getPlayer().dropMessage(6, "输入的地图不存在.");
                            return 0;
                        }
                        MaplePortal targetPortal = null;
                        if (splitted.length > 2) {
                            try {
                                targetPortal = target.getPortal(Integer.parseInt(splitted[2]));
                            } catch (IndexOutOfBoundsException e) {
                                // noop, assume the gm didn't know how many portals there are
                                c.getPlayer().dropMessage(5, "Invalid portal selected.");
                            } catch (NumberFormatException a) {
                                // noop, assume that the gm is drunk
                            }
                        }
                        if (targetPortal == null) {
                            targetPortal = target.getPortal(0);
                        }
                        c.getPlayer().changeMap(target, targetPortal);
                    } else {
                        victim = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(splitted[1]);
                        c.getPlayer().dropMessage(6, "正在切换频道，请等待...");
                        if (victim.getMapId() != c.getPlayer().getMapId()) {
                            MapleMap mapp = c.getChannelServer().getMapFactory().getMap(victim.getMapId());
                            c.getPlayer().changeMap(mapp, mapp.findClosestPortal(victim.getTruePosition()));
                        }
                        c.getPlayer().changeChannel(ch);
                    }
                } catch (Exception e) {
                    c.getPlayer().dropMessage(6, "出现错误: " + e.getMessage());
                    return 0;
                }
            }
            return 1;
        }
    }


    public static class 监禁 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 3) {
                c.getPlayer().dropMessage(6, "用法: !监禁 [玩家名字] [多少分钟, 0 = forever]");
                return 0;
            }
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            int minutes = Math.max(0, Integer.parseInt(splitted[2]));
            if (victim != null && c.getPlayer().getGMLevel() >= victim.getGMLevel()) {
                MapleMap target = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(GameConstants.JAIL);
                victim.getQuestNAdd(MapleQuest.getInstance(GameConstants.JAIL_QUEST)).setCustomData(String.valueOf(minutes * 60));
                victim.changeMap(target, target.getPortal(0));
                victim.gainWarning(true);
            } else {
                c.getPlayer().dropMessage(6, "请确保要监禁的玩家处于在线状态.");
                return 0;
            }
            return 1;
        }
    }

//
//    public static class ListAllSquads extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            for (ChannelServer cserv : ChannelServer.getAllInstances()) {
//                for (Map.Entry<MapleSquadType, MapleSquad> squads : cserv.getAllSquads().entrySet()) {
//                    c.getPlayer().dropMessage(5, "[频道 " + cserv.getChannel() + "] 类型: " + squads.getKey().name() + ", 队长: " + squads.getValue().getLeader().getName() + ", 状态: " + squads.getValue().getStatus() + ", 成员总数: " + squads.getValue().getSquadSize() + ", 拒绝成员总数: " + squads.getValue().getBannedMemberSize());
//                }
//            }
//            return 1;
//        }
//    }
//
//
//    public static class Say extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length > 1) {
//                StringBuilder sb = new StringBuilder();
//                sb.append("[");
//                if (!c.getPlayer().isGM()) {
//                    sb.append("管理员 ");
//                }
//                sb.append(c.getPlayer().getName());
//                sb.append("] ");
//                sb.append(StringUtil.joinStringFrom(splitted, 1));
//                WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(c.getPlayer().isGM() ? 6 : 5, sb.toString()));
//            } else {
//                c.getPlayer().dropMessage(6, "用法: say <message>");
//                return 0;
//            }
//            return 1;
//        }
//    }
//
//
//    public static class Letter extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 3) {
//                c.getPlayer().dropMessage(6, "用法: !letter <color (green/red)> <word>");
//                return 0;
//            }
//            int start, nstart;
//            if (splitted[1].equalsIgnoreCase("green")) {
//                start = 3991026;
//                nstart = 3990019;
//            } else if (splitted[1].equalsIgnoreCase("red")) {
//                start = 3991000;
//                nstart = 3990009;
//            } else {
//                c.getPlayer().dropMessage(6, "未知的颜色!");
//                return 0;
//            }
//            String splitString = StringUtil.joinStringFrom(splitted, 2);
//            java.util.List<Integer> chars = new ArrayList<>();
//            splitString = splitString.toUpperCase();
//            // System.out.println(splitString);
//            for (int i = 0; i < splitString.length(); i++) {
//                char chr = splitString.charAt(i);
//                if (chr == ' ') {
//                    chars.add(-1);
//                } else if ((chr) >= 'A' && (chr) <= 'Z') {
//                    chars.add((int) (chr));
//                } else if ((chr) >= '0' && (chr) <= ('9')) {
//                    chars.add((chr) + 200);
//                }
//            }
//            final int w = 32;
//            int dStart = c.getPlayer().getPosition().x - (splitString.length() / 2 * w);
//            for (Integer i : chars) {
//                if (i == -1) {
//                    dStart += w;
//                } else if (i < 200) {
//                    int val = start + i - ('A');
//                    client.inventory.Item item = new client.inventory.Item(val, (byte) 0, (short) 1);
//                    c.getPlayer().getMap().spawnItemDrop(c.getPlayer(), c.getPlayer(), item, new Point(dStart, c.getPlayer().getPosition().y), false, false);
//                    dStart += w;
//                } else if (i >= 200 && i <= 300) {
//                    int val = nstart + i - ('0') - 200;
//                    client.inventory.Item item = new client.inventory.Item(val, (byte) 0, (short) 1);
//                    c.getPlayer().getMap().spawnItemDrop(c.getPlayer(), c.getPlayer(), item, new Point(dStart, c.getPlayer().getPosition().y), false, false);
//                    dStart += w;
//                }
//            }
//            return 1;
//        }
//    }
//
//
//    public static class Find extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length == 1) {
//                c.getPlayer().dropMessage(6, splitted[0] + ": <NPC> <MOB> <ITEM> <MAP> <SKILL> <QUEST>");
//            } else if (splitted.length == 2) {
//                c.getPlayer().dropMessage(6, "Provide something to search.");
//            } else {
//                String type = splitted[1];
//                String search = StringUtil.joinStringFrom(splitted, 2);
//                MapleData data = null;
//                MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz"));
//                c.getPlayer().dropMessage(6, "<<Type: " + type + " | Search: " + search + ">>");
//
//                if (type.equalsIgnoreCase("NPC")) {
//                    java.util.List<String> retNpcs = new ArrayList<>();
//                    data = dataProvider.getData("Npc.img");
//                    java.util.List<Pair<Integer, String>> npcPairList = new LinkedList<>();
//                    for (MapleData npcIdData : data.getChildren()) {
//                        npcPairList.add(new Pair<>(Integer.parseInt(npcIdData.getName()), MapleDataTool.getString(npcIdData.getChildByPath("name"), "NO-NAME")));
//                    }
//                    for (Pair<Integer, String> npcPair : npcPairList) {
//                        if (npcPair.getRight().toLowerCase().contains(search.toLowerCase())) {
//                            retNpcs.add(npcPair.getLeft() + " - " + npcPair.getRight());
//                        }
//                    }
//                    if (retNpcs != null && retNpcs.size() > 0) {
//                        for (String singleRetNpc : retNpcs) {
//                            c.getPlayer().dropMessage(6, singleRetNpc);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No NPC's Found");
//                    }
//
//                } else if (type.equalsIgnoreCase("MAP")) {
//                    java.util.List<String> retMaps = new ArrayList<>();
//                    data = dataProvider.getData("Map.img");
//                    java.util.List<Pair<Integer, String>> mapPairList = new LinkedList<>();
//                    for (MapleData mapAreaData : data.getChildren()) {
//                        for (MapleData mapIdData : mapAreaData.getChildren()) {
//                            mapPairList.add(new Pair<>(Integer.parseInt(mapIdData.getName()), MapleDataTool.getString(mapIdData.getChildByPath("streetName"), "NO-NAME") + " - " + MapleDataTool.getString(mapIdData.getChildByPath("mapName"), "NO-NAME")));
//                        }
//                    }
//                    for (Pair<Integer, String> mapPair : mapPairList) {
//                        if (mapPair.getRight().toLowerCase().contains(search.toLowerCase())) {
//                            retMaps.add(mapPair.getLeft() + " - " + mapPair.getRight());
//                        }
//                    }
//                    if (retMaps != null && retMaps.size() > 0) {
//                        for (String singleRetMap : retMaps) {
//                            c.getPlayer().dropMessage(6, singleRetMap);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No Maps Found");
//                    }
//                } else if (type.equalsIgnoreCase("MOB")) {
//                    java.util.List<String> retMobs = new ArrayList<>();
//                    data = dataProvider.getData("Mob.img");
//                    java.util.List<Pair<Integer, String>> mobPairList = new LinkedList<>();
//                    for (MapleData mobIdData : data.getChildren()) {
//                        mobPairList.add(new Pair<>(Integer.parseInt(mobIdData.getName()), MapleDataTool.getString(mobIdData.getChildByPath("name"), "NO-NAME")));
//                    }
//                    for (Pair<Integer, String> mobPair : mobPairList) {
//                        if (mobPair.getRight().toLowerCase().contains(search.toLowerCase())) {
//                            retMobs.add(mobPair.getLeft() + " - " + mobPair.getRight());
//                        }
//                    }
//                    if (retMobs != null && retMobs.size() > 0) {
//                        for (String singleRetMob : retMobs) {
//                            c.getPlayer().dropMessage(6, singleRetMob);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No Mobs Found");
//                    }
//
//                } else if (type.equalsIgnoreCase("ITEM")) {
//                    java.util.List<String> retItems = new ArrayList<>();
//                    for (Map.Entry<Integer, String> entry : MapleItemInformationProvider.getInstance().getAllItemNames().entrySet()) {
//                        if (entry.getValue().toLowerCase().contains(search.toLowerCase())) {
//                            retItems.add(entry.getKey() + " - " + entry.getValue());
//                        }
//                    }
//                    if (retItems != null && retItems.size() > 0) {
//                        for (String singleRetItem : retItems) {
//                            c.getPlayer().dropMessage(6, singleRetItem);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No Items Found");
//                    }
//                } else if (type.equalsIgnoreCase("QUEST")) {
//                    java.util.List<String> retItems = new ArrayList<>();
//                    for (MapleQuest itemPair : MapleQuest.getAllInstances()) {
//                        if (itemPair.getName().length() > 0 && itemPair.getName().toLowerCase().contains(search.toLowerCase())) {
//                            retItems.add(itemPair.getId() + " - " + itemPair.getName());
//                        }
//                    }
//                    if (retItems != null && retItems.size() > 0) {
//                        for (String singleRetItem : retItems) {
//                            c.getPlayer().dropMessage(6, singleRetItem);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No Quests Found");
//                    }
//                } else if (type.equalsIgnoreCase("SKILL")) {
//                    java.util.List<String> retSkills = new ArrayList<>();
//                    for (Map.Entry<Integer, String> skil : SkillFactory.getAllSkills().entrySet()) {
//                        if (skil.getValue() != null && skil.getValue().toLowerCase().contains(search.toLowerCase())) {
//                            retSkills.add(skil.getKey() + " - " + skil.getValue());
//                        }
//                    }
//                    if (!retSkills.isEmpty() && retSkills.size() > 0) {
//                        for (String singleRetSkill : retSkills) {
//                            c.getPlayer().dropMessage(6, singleRetSkill);
//                        }
//                    } else {
//                        c.getPlayer().dropMessage(6, "No skills Found");
//                    }
//                } else {
//                    c.getPlayer().dropMessage(6, "Sorry, that search call is unavailable");
//                }
//            }
//            return 0;
//        }
//    }
//
//
//    public static class ID extends Find {
//    }
//
//
//    public static class LookUp extends Find {
//    }
//
//
//    public static class Search extends Find {
//    }

//
//    public static class WhosFirst extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            //probably bad way to do it
//            final long currentTime = System.currentTimeMillis();
//            java.util.List<Pair<String, Long>> players = new ArrayList<>();
//            for (MapleCharacter chr : c.getPlayer().getMap().getCharactersThreadsafe()) {
//                if (!chr.isIntern()) {
//                    players.add(new Pair<>(MapleCharacterUtil.makeMapleReadable(chr.getName()) + (currentTime - chr.getCheatTracker().getLastAttack() > 600000 ? " (AFK)" : ""), chr.getChangeTime()));
//                }
//            }
//            players.sort(new WhoComparator());
//            StringBuilder sb = new StringBuilder("List of people in this map in order, counting AFK (10 minutes):  ");
//            for (Pair<String, Long> z : players) {
//                sb.append(z.left).append(", ");
//            }
//            c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//            return 0;
//        }
//
//
//        public static class WhoComparator implements Comparator<Pair<String, Long>>, Serializable {
//
//            /**
//             *
//             */
//            private static final long serialVersionUID = -595003339775165157L;
//
//            @Override
//            public int compare(Pair<String, Long> o1, Pair<String, Long> o2) {
//                if (o1.right > o2.right) {
//                    return 1;
//                } else if (o1.right == o2.right) {
//                    return 0;
//                } else {
//                    return -1;
//                }
//            }
//        }
//    }
//
//
//    public static class WhosLast extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                StringBuilder sb = new StringBuilder("用法: !whoslast [type] where type can be:  ");
//                for (MapleSquadType t : MapleSquadType.values()) {
//                    sb.append(t.name()).append(", ");
//                }
//                c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//                return 0;
//            }
//            final MapleSquadType t = MapleSquadType.valueOf(splitted[1].toLowerCase());
//            if (t == null) {
//                StringBuilder sb = new StringBuilder("用法: !whoslast [type] where type can be:  ");
//                for (MapleSquadType z : MapleSquadType.values()) {
//                    sb.append(z.name()).append(", ");
//                }
//                c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//                return 0;
//            }
//            if (t.queuedPlayers.get(c.getChannel()) == null) {
//                c.getPlayer().dropMessage(6, "The queue has not been initialized in this channel yet.");
//                return 0;
//            }
//            c.getPlayer().dropMessage(6, "Queued players: " + t.queuedPlayers.get(c.getChannel()).size());
//            StringBuilder sb = new StringBuilder("List of participants:  ");
//            for (Pair<String, String> z : t.queuedPlayers.get(c.getChannel())) {
//                sb.append(z.left).append('(').append(z.right).append(')').append(", ");
//            }
//            c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//            return 0;
//        }
//    }
//
//
//    public static class WhosNext extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            if (splitted.length < 2) {
//                StringBuilder sb = new StringBuilder("用法: !whosnext [type] where type can be:  ");
//                for (MapleSquadType t : MapleSquadType.values()) {
//                    sb.append(t.name()).append(", ");
//                }
//                c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//                return 0;
//            }
//            final MapleSquadType t = MapleSquadType.valueOf(splitted[1].toLowerCase());
//            if (t == null) {
//                StringBuilder sb = new StringBuilder("用法: !whosnext [type] where type can be:  ");
//                for (MapleSquadType z : MapleSquadType.values()) {
//                    sb.append(z.name()).append(", ");
//                }
//                c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//                return 0;
//            }
//            if (t.queue.get(c.getChannel()) == null) {
//                c.getPlayer().dropMessage(6, "The queue has not been initialized in this channel yet.");
//                return 0;
//            }
//            c.getPlayer().dropMessage(6, "Queued players: " + t.queue.get(c.getChannel()).size());
//            StringBuilder sb = new StringBuilder("List of participants:  ");
//            final long now = System.currentTimeMillis();
//            for (Pair<String, Long> z : t.queue.get(c.getChannel())) {
//                sb.append(z.left).append('(').append(StringUtil.getReadableMillis(z.right, now)).append(" ago),");
//            }
//            c.getPlayer().dropMessage(6, sb.toString().substring(0, sb.length() - 2));
//            return 0;
//        }
//    }
//
//
//    public static class WarpMap extends CommandExecute {
//
//        @Override
//        public int execute(MapleClient c, String[] splitted) {
//            try {
//                MapleMap target = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(splitted[1]));
//                if (target == null) {
//                    c.getPlayer().dropMessage(6, "输入的地图不存在.");
//                    return 0;
//                }
//                MapleMap from = c.getPlayer().getMap();
//                for (MapleCharacter chr : from.getCharactersThreadsafe()) {
//                    chr.changeMap(target, target.getPortal(0));
//                }
//            } catch (Exception e) {
//                c.getPlayer().dropMessage(5, "错误: " + e.getMessage());
//                return 0; //assume drunk GM
//            }
//            return 1;
//        }
//    }





    public static class 查看封号 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "[用法] !查看封号 <角色名字>");
                return 0;
            }
            String msg = MapleClient.getAccInfoByName(splitted[1], c.getPlayer().isAdmin());
            if (msg != null) {
                c.getPlayer().dropMessage(6, msg);
            } else {
                c.getPlayer().dropMessage(6, "输入的角色名字错误，无法找到信息.");
            }
            return 1;
        }
    }



    public static class 测谎仪 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "!测谎仪 <角色名字>");
                return 0;
            }
            MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
            if (chr != null && c.getPlayer().getGMLevel() >= chr.getGMLevel()) {
                if (chr.getMapId() == GameConstants.JAIL) {
                    c.getPlayer().dropMessage(6, "玩家 " + chr.getName() + " 在监狱地图无法对其使用.");
                } else if (!chr.getAntiMacro().startLieDetector(chr.getName(), false, false)) {
                    c.getPlayer().dropMessage(6, "对玩家 " + chr.getName() + " 使用测谎仪失败.");
                } else {
                    c.getPlayer().dropMessage(6, "已成功对玩家 " + chr.getName() + " 使用测谎仪.");
                }
            } else {
                c.getPlayer().dropMessage(6, "请确保要测谎的玩家处于在线状态.");
                return 0;
            }
            return 1;
        }
    }
    public static class 满技能 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            HashMap<Integer, SkillEntry> sDate = new HashMap<>();
            for (Integer skillid : SkillFactory.getAllSkills().keySet()) {
                Skill skill = SkillFactory.getSkill(skillid);
                if (skill != null && SkillConstants.isApplicableSkill(skillid) && skillid < 90000000) { //no db/additionals/resistance skills
                    sDate.put(skillid, new SkillEntry((byte) skill.getMaxLevel(), (byte) skill.getMaxLevel(), SkillFactory.getDefaultSExpiry(skill)));
                }
            }
            c.getPlayer().changeSkillsLevel(sDate);
            sDate.clear();
            return 1;
        }
    }
    public static class 满职业技能 extends CommandExecute {

        @Override
        public int execute(MapleClient c, String[] splitted) {
            List<Integer> skillIds = new ArrayList<>();
            HashMap<Integer, SkillEntry> sDate = new HashMap<>();
            for (Integer skillid : SkillFactory.getAllSkills().keySet()) {
                Skill skill = SkillFactory.getSkill(skillid);
                if (skill != null && skill.canBeLearnedBy(c.getPlayer().getJob()) && !JobConstants.is新手职业(skillid / 10000) && !skill.isSpecialSkill() && !skill.isHyperSkill()) {
                    sDate.put(skillid, new SkillEntry((byte) skill.getMaxLevel(), (byte) skill.getMaxLevel(), SkillFactory.getDefaultSExpiry(skill)));
                    skillIds.add(skillid);
                }
            }
            c.getPlayer().changeSkillsLevel(sDate);
            Collections.sort(skillIds);
//        if (getPlayer().isShowPacket()) {
//            String job = "Skill\\" + JobConstants.getJobNameById(getPlayer().getJob()) + ".txt";
//            for (Integer skillId : skillIds) {
//                for (Entry<Integer, SkillEntry> data : sDate.entrySet()) {
//                    if (data.getKey().getId() == skillId) {
//                        String txt = "public static final int " + data.getKey().getName() + " = " + data.getKey().getId() + "; //技能最大等级" + data.getKey().getMaxLevel();
//                        FileoutputUtil.log(job, txt, true);
//                    }
//                }
//            }
//        }
            sDate.clear();
            skillIds.clear();
            return 1;
        }
    }

    public static class 解封 extends CommandExecute {


        protected boolean hellban = false;

        private String getCommand() {
            if (hellban) {
                return "UnHellBan";
            } else {
                return "UnBan";
            }
        }

        @Override
        public int execute(MapleClient c, String[] splitted) {
            if (splitted.length < 2) {
                c.getPlayer().dropMessage(6, "[用法] !解封 <角色名>");
                return 0;
            }
            byte ret;
            if (hellban) {
                ret = MapleClient.unHellban(splitted[1]);
            } else {
                ret = MapleClient.unban(splitted[1]);
            }
            if (ret == -2) {
                c.getPlayer().dropMessage(6, "[" + getCommand() + "] 数据库查询出错.");
                return 0;
            } else if (ret == -1) {
                c.getPlayer().dropMessage(6, "[" + getCommand() + "] 角色 " + splitted[1] + " 不存在.");
                return 0;
            } else {
                c.getPlayer().dropMessage(6, "[" + getCommand() + "] 已经成功将玩家 " + splitted[1] + " 解除封停!");
                log.info("[命令] 管理员 " + c.getPlayer().getName() + " 将玩家 " + splitted[1] + " 解除封号.");
            }
            byte ret_ = MapleClient.unbanIPMacs(splitted[1]);
            if (ret_ == -2) {
                c.getPlayer().dropMessage(6, "[UnbanIP] 数据库查询出错.");
            } else if (ret_ == -1) {
                c.getPlayer().dropMessage(6, "[UnbanIP] 输入的角色不存在.");
            } else if (ret_ == 0) {
                c.getPlayer().dropMessage(6, "[UnbanIP] No IP or Mac with that character exists!");
            } else if (ret_ == 1) {
                c.getPlayer().dropMessage(6, "[UnbanIP] IP/Mac -- one of them was found and unbanned.");
            } else if (ret_ == 2) {
                c.getPlayer().dropMessage(6, "[UnbanIP] Both IP and Macs were unbanned.");
            }
            return ret_ > 0 ? 1 : 0;
        }
    }



}
